// ==UserScript==
// @name        YahooPlayerPage
// @namespace   glenncarr.com
// @description Display more information on player
// @include     http://sports.yahoo.com/*/players/*
// @version     1
// @grant       none
// ==/UserScript==

var bio = document.evaluate( "//div[@class='bio']//dt[contains(.,'Born')]/../dd", document.body, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );
if ( bio.snapshotLength > 0 )
{ 
	var dtBirth = new Date( bio.snapshotItem( 0 ).innerHTML );
	var dtNow = new Date();
	var msAge = ( dtNow - dtBirth );
	var age = secondsToTimeSpan( msAge / 1000 );
	bio.snapshotItem( 0 ).innerHTML += " (" + age.Years + " yrs, " + age.Months + " mos)";
}
  
function secondsToTimeSpan(seconds)
{
	var numyears = Math.floor(seconds / 31536000);
	var numdays = Math.floor((seconds % 31536000) / 86400); 
	var nummonths = Math.floor(numdays / 30.41666666666667);
	var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600);
	var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60);
	var numseconds = (((seconds % 31536000) % 86400) % 3600) % 60;
	//return numyears + " years " + nummonths + " months " + numdays + " days " + numhours + " hours " + numminutes + " minutes " + numseconds + " seconds";
	return { "Years":numyears, "Months":nummonths }
}